package com.hyperboost.controller;

import com.hyperboost.constant.MessageConstant;
import com.hyperboost.dto.ShareCommentDTO;
import com.hyperboost.dto.ShareCommentPageQueryDTO;
import com.hyperboost.dto.ShareCommentReplyQueryDTO;
import com.hyperboost.result.PageResult;
import com.hyperboost.result.Result;
import com.hyperboost.service.ShareCommentService;
import com.hyperboost.vo.ShareCommentReplyVO;
import com.hyperboost.vo.ShareCommentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 分享评论相关接口
 */
@RestController
@RequestMapping("/frontend/shareComment")
public class ShareCommentController {

    @Autowired
    private ShareCommentService commentService;

    /**
     * 发布评论
     *
     * @param commentDTO
     * @return
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody ShareCommentDTO commentDTO){
        commentService.addComment(commentDTO);
        return Result.success(MessageConstant.ADD_COMMENT_SUCCESS);
    }


    /**
     * 删除评论
     *
     * @param commentId
     * @return
     */
    @DeleteMapping({"/{commentId}"})
    public Result deleteComment(@PathVariable Long commentId){
        commentService.deleteComment(commentId);
        return Result.success(MessageConstant.DELETE_COMMENT_SUCCESS);
    }

    /**
     * 分页查询顶级评论
     *
     * @param pageQueryDTO
     * @return
     */
    @GetMapping("/pageComment")
    public Result<PageResult<ShareCommentVO>> pageQueryComment(ShareCommentPageQueryDTO pageQueryDTO){
        return Result.success(commentService.pageQueryComment(pageQueryDTO));
    }

    /**
     * 展示回复评论列表
     *
     * @param pageQueryDTO
     * @return
     */
    @GetMapping("/listReplyComment")
    public Result<List<ShareCommentReplyVO>> listQueryReplyComment(ShareCommentReplyQueryDTO pageQueryDTO){
        return Result.success(commentService.listQueryReplyComment(pageQueryDTO));
    }
}
